package com.example.web.controller;

/**
 * Created by liuw on 2017/11/14.
 */

import com.example.starter.dto.ResultBean;
import com.example.starter.dto.User;
import com.example.web.dto.DatePageQuery;
import com.example.web.validation.annotation.DatePageQueryCheck;

import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RequestMapping("/config")
@RestController
//方法参数检验必须注解
@Validated
public class ConfigController {

    /*@Autowired
    ConfigService configService;*/


    @GetMapping
    public ResultBean<String> getOne(@DatePageQueryCheck DatePageQuery datePageQuery, @Range(min = 1, max = 9, message = "{aa}") @RequestParam Integer bb) {

        return new ResultBean<String>("ok");
    }

    @GetMapping("/error")
    public ResultBean<String> error() {
        log.info(System.currentTimeMillis() + "");
        throw new RuntimeException("发生错误");
    }

    /*@GetMapping("/all")
    public ResultBean<Collection<Config>> getAll() {
        return new ResultBean<Collection<Config>>(configService.getAll());
    }

    @PostMapping("/add")
    public ResultBean<Long> add(Config config) {
        return new ResultBean<Long>(configService.add(config));
    }

    @PostMapping("/delete")
    public ResultBean<Boolean> delete(long id) {
        return new ResultBean<Boolean>(configService.delete(id));
    }*/
}